//Author: xiaruize
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define int long long
#define pii pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, b, a) for (int i = (b); i >= (a); i--)
int testcase = 1, caseid;
const int N = 1e5 + 10;

int n, m, len, lim;
struct car
{
    int st;
    double v0, a;
    pii rg;
    bool issafe;

    void clear()
    {
        st = v0 = a = issafe = 0;
        rg = {0, 0};
    }
} s[N];
double pos[N];

bool check(int x, int ps)
{
    ps = pos[ps];
    if (ps < s[x].st)
        return false;
    int ss = ps - s[x].st;
    return s[x].v0 * s[x].v0 + 2 * s[x].a * ss > lim * lim;
}

void solve()
{
    rep(i, 1, n) s[i].clear();
    cin >> n >> m >> len >> lim;
    rep(i, 1, n)
    {
        cin >> s[i].st >> s[i].v0 >> s[i].a;
    }
    rep(i, 1, m) cin >> pos[i];
    rep(i, 1, n)
    {
        int st = s[i].st, v0 = s[i].v0, a = s[i].a;
        pii &rg = s[i].rg;
        if (a == 0)
        {
            if (v0 > lim)
            {
                int l = lower_bound(pos + 1, pos + m + 1, st) - pos;
                if (l == m + 1)
                    s[i].issafe = true;
                else
                    rg = {l, m};
            }
            else
            {
                s[i].issafe = true;
            }
        }
        else if (a > 0)
        {
            if (v0 > lim)
            {
                int l = lower_bound(pos + 1, pos + m + 1, st) - pos;
                if (l == m + 1)
                    s[i].issafe = true;
                else
                    rg = {l, m};
            }
            else
            {
                int l = lower_bound(pos + 1, pos + m + 1, st) - pos, r = m + 1;
                while (l < r)
                {
                    int mid = l + r >> 1;
                    if (check(i, mid))
                        r = mid;
                    else
                        l = mid + 1;
                }
                if (l <= m)
                    rg = {l, m};
                else
                    s[i].issafe = true;
            }
        }
        else
        {
            if (v0 <= lim)
            {
                s[i].issafe = true;
                continue;
            }
            int l = lower_bound(pos + 1, pos + m + 1, st) - pos - 1, r = m;
            int lb = l + 1;
            while (l < r)
            {
                int mid = l + r + 1 >> 1;
                if (check(i, mid))
                    l = mid;
                else
                    r = mid - 1;
            }
            if (l >= lb)
                rg = {lb, l};
            else
                s[i].issafe = true;
        }
    }
    int res = 0;
    vector<pii> vec;
    rep(i, 1, n)
    {
        // cerr << i << ' ' << s[i].rg.first << ' ' << s[i].rg.second << endl;
        if (s[i].issafe)
            continue;
        int lb = s[i].rg.first, rb = s[i].rg.second;
        int tmp = rb - lb + 1;
        if (tmp > 0)
        {
            res++;
            vec.push_back({lb, rb});
        }
    }
    cout << res << ' ';
    if (res == 0)
    {
        cout << m << endl;
        return;
    }
    res = 0;
    sort(vec.begin(), vec.end());
    int cur = -1;
    for (pii v : vec)
    {
        int l = v.first, r = v.second;
        if (cur < l)
        {
            if (cur != -1)
                res++;
            cur = r;
        }
        cur = min(cur, r);
    }
    res++;
    cout << m - res << endl;
}

signed main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> testcase;
    while (testcase--)
        solve();
    return 0;
}
// g++ detect.cpp -o detect -std=c++14 -Wall -fsanitize=address,undefined -O2